package com.cn.redis.client.impl;

import com.cn.redis.client.RedisClient;
import com.cn.redis.exception.RedisConnectException;
import org.springframework.data.redis.core.RedisTemplate;

public class RedisClientTemplateImpl implements RedisClient {
    private RedisTemplate<String, Object> redisTemplate;

    public RedisClientTemplateImpl() {
    }

    public RedisClientTemplateImpl(RedisTemplate<String, Object> redisTemplate) {
        this.redisTemplate = redisTemplate;
    }

    public long incrBy(String seqName, int step) {
        long max = 0L;

        try {
            max = this.redisTemplate.opsForValue().increment(seqName, (long)step);
            return max;
        } catch (Exception var6) {
            var6.printStackTrace();
            throw new RedisConnectException("redis连接失败");
        }
    }

    public void init() {
    }

    public RedisTemplate<String, Object> getRedisTemplate() {
        return this.redisTemplate;
    }

    public void setRedisTemplate(RedisTemplate<String, Object> redisTemplate) {
        this.redisTemplate = redisTemplate;
    }
}
